import 'dart:io';

import 'package:device_info_plus/device_info_plus.dart';
import 'package:fk_user_agent/fk_user_agent.dart';

Future<Map<String, dynamic>> loadDeviceInfo() async {
  await FkUserAgent.init();

  String deviceName = 'unknown';
  DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
  if (Platform.isIOS) {
    IosDeviceInfo iosInfo = await deviceInfo.iosInfo;
    deviceName = iosInfo.utsname.machine ?? deviceName;
  } else if (Platform.isAndroid) {
    AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
    deviceName = androidInfo.model ?? deviceName;
  }

  return {
    'userAgent': FkUserAgent.userAgent,
    'webViewUserAgent': FkUserAgent.webViewUserAgent,
    'deviceName': deviceName,
    'isIOS': Platform.isIOS,
    'isAndroid': Platform.isAndroid,
  };
}
